package com.hgw.Demo04_CreateInterator.Exercises19_8_4;

import com.hgw.Demo04_CreateInterator.examples.AbstractIterator;

import java.util.ArrayList;

/**
 * Data time:2021/12/18 14:10
 * StudentID:2019112118
 * Author:hgw
 * Description: 客户端测试类
 */
public class Client {
    public static void main(String[] args) {
        ArrayList<TC> tcs = new ArrayList<>();
        tcs.add(new TC("cctv", "中央广播电视台"));
        tcs.add(new TC("61", "少儿频道"));
        tcs.add(new TC("cczj", "浙江广播电视台"));
        tcs.add(new TC("ccah", "安徽广播电视台"));

        AbstractTCList tcList;
        AbstractTCListIterator iterator;

        tcList = new TCList(tcs);                   //创建聚合对象
        iterator = tcList.createTCListIterator();   //创建迭代器对象
        while (!iterator.isLast()) {
            System.out.println(iterator.getNextItem() + "；");
            iterator.next();
        }
        tcList.addTC(new TC("ccjn", "江南频道"));

        System.out.println("------------------------");
        while (!iterator.isFirst()) {
            System.out.println(iterator.getPreviousItem() + ";");
            iterator.previous();
        }
    }
}
